/**
 * Copyright (c) 2019 格创东智 All rights reserved.
 *
 * http://www.getech.cn
 *
 * 版权所有，侵权必究！
 */

package cn.getech.data.development.constant;

/**
 * 常量
 *
 * @author zenith
 */
public class Constant {

    /**
     * 定时任务状态
     *
     * @author chenshun
     * @email sunlightcs@gmail.com
     * @date 2016年12月3日 上午12:07:22
     */
    public enum ScheduleStatus {
        /**
         * 正常
         */
    	NORMAL(0),
        /**
         * 暂停
         */
    	PAUSE(1);

        private int value;

        ScheduleStatus(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }

    /**
     * 实时任务类型
     */
    public enum RealTimeTaskType {

    	FLINK(1, "FLINK API","flink_api"),
        FLINK_SQL(2, "FLINK SQL","flink_sql"),
        FLINK_SQL_DAG(3, "FLINK SQL DAG","flink_sql_dag")
        ,REAL_TIME_COLLECTION(4, "实时采集","real_time_collection")
        ;

        private Integer code;
        private String name;
        private String desc;

        RealTimeTaskType(Integer code, String name, String desc) {
            this.code = code;
            this.name = name;
            this.desc = desc;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public String getDesc() {
            return desc;
        }

        public static String getDescByCode(Integer code) {
            for (RealTimeTaskType taskType : RealTimeTaskType.values()) {
                if (taskType.getCode().equals(code)) {
                    return taskType.getDesc();
                }
            }
            return "";
        }
        public static String getNameByCode(Integer code) {
            for (RealTimeTaskType taskType : RealTimeTaskType.values()) {
                if (taskType.getCode().equals(code)) {
                    return taskType.getName();
                }
            }
            return "";
        }
    }

    /**
     * 实时任务日志类型
     */
    public enum RealTimeTaskLogType {

    	CREATE(1, "创建"),
    	UPDATE(2, "编辑"),
    	DELETE(3, "删除"),
    	RUN(4, "运行"),
    	STOP(5, "停止");

        private int code;
        private String name;

        RealTimeTaskLogType(int code, String name) {
            this.code = code;
            this.name = name;
        }

        public int getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public static String valueOfCode(Integer code) {
            String name = "";
            for (RealTimeTaskLogType logType : RealTimeTaskLogType.values()) {
                if (code.intValue() == logType.getCode()) {
                    name = logType.getName();
                    break;
                }
            }
            return name;
        }
    }

}
